﻿<phone:PhoneApplicationPage 
    x:Class="MyDeeWeibo.PageViews.SecretTimeline"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    Loaded="PhoneApplicationPage_Loaded"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="StatusTemplateComplex">
            <Grid Margin="0,12,8,10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel x:Name="LeftPanel" Orientation="Vertical" d:LayoutOverrides="Height" Margin="0,0,8,0">
                    <Border x:Name="ProfileBorder" BorderThickness="1" Width="64" Height="64" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{StaticResource TransparentBrush}">
                        <Canvas Margin="0">
                            <Image x:Name="ProfileImage" Source="{Binding user.profile_img}" Height="56" Width="56" Canvas.Left="2" Canvas.Top="2"/>
                            <Image x:Name="VerifyLogo" Height="20" Width="20" Canvas.Left="45" Canvas.Top="45" Source="/Resources/Images/SinaResource.Verifier.png" Visibility="{Binding user.IsVerified}" Stretch="UniformToFill"/>
                        </Canvas>
                    </Border>
                </StackPanel>

                <StackPanel x:Name="RightPanel" Grid.Column="1" Grid.Row="0" Margin="0" Orientation="Vertical" d:LayoutOverrides="Height" >
                    <Grid x:Name="HeaderGrid" Margin="0,4,0,10" UseLayoutRounding="True" Height="30">
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="1,0.5" SpreadMethod="Reflect" StartPoint="0,0.5" Opacity="0.4">
                                <GradientStop Color="{Binding Source={StaticResource AppSettings}, Path=colorSaved}" Offset="0"/>
                                <GradientStop Color="White" Offset="1"/>
                            </LinearGradientBrush>
                        </Grid.Background>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock x:Name="UserName" Height="30" Margin="-10" FontSize="20" Text="{Binding user.name}" Padding="10,0" Foreground="Black" LineHeight="16" />
                        <TextBlock x:Name="CreateTimeBlock" Text="{Binding CreatedAt}" FontSize="20" VerticalAlignment="Bottom" Grid.Column="1" Foreground="{StaticResource GreyBrush}" Margin="0" Height="30"/>
                    </Grid>
                    <TextBlock x:Name="StatusBlock" Text="{Binding text}" TextWrapping="Wrap" FontSize="21.333" Foreground="Black" />
                    <Image x:Name="ThumbImage" Source="{Binding thumbnail_pic}" HorizontalAlignment="Left" Stretch="Uniform" Visibility="{Binding IsThumbnail}" Margin="0,12,0,0" VerticalAlignment="Top" Height="120"/>
                    <Border x:Name="RetweetBorder" Margin="0,12,0,0" Padding="8,12" Visibility="{Binding IsRetweetedStatus}" CornerRadius="10" BorderThickness="1" Background="#FFEDEDED" BorderBrush="#FFC2C2C2">
                        <StackPanel>
                            <TextBlock x:Name="RetweetUserBlock" TextWrapping="Wrap" Text="{Binding retweeted_status.user.name}" Margin="0,0,0,10" Foreground="Black" FontWeight="Bold"/>
                            <TextBlock x:Name="RetweetStatusBlock" TextWrapping="Wrap" Text="{Binding retweeted_status.text}" Foreground="Black"/>
                            <Image x:Name="RetweetThumbImage" 
                                   Margin="0,12,0,0" 
                                   Stretch="Uniform" 
                                   Source="{Binding retweeted_status.thumbnail_pic}" 
                                   Visibility="{Binding retweeted_status.IsThumbnail}" 
                                   HorizontalAlignment="Left" 
                                   VerticalAlignment="Top" 
                                   Height="120"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <Grid x:Name="FooterGrid" Margin="0,12,0,0" Grid.Row="1" Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <StackPanel x:Name="SourcePanel" Orientation="Horizontal" HorizontalAlignment="Left" d:LayoutOverrides="HorizontalAlignment, GridBox">
                        <Image x:Name="StatusPicHint" Source="/Resources/Images/Status_Pic.png" Visibility="{Binding IsThumbnail}" Margin="0,0,0,-2" Width="30"/>
                        <TextBlock x:Name="SourceBlock"
                        	Text="{Binding Source}" 
                        	d:LayoutOverrides="Width" 
                        	HorizontalAlignment="Left" 
                        	VerticalAlignment="Bottom" 
                        	FontSize="18.667" Foreground="{StaticResource GreyBrush}"/>
                        <Image x:Name="StatusComment" Source="/Resources/Images/Status_Comment.png" Margin="0,0,0,-2" Width="30"/>
                        <TextBlock x:Name="CommentCount"
    						Text="{Binding comments_count}" 
    						d:LayoutOverrides="Width" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom" 
    						FontSize="18.667" Foreground="{StaticResource GreyBrush}"/>
                        <Image x:Name="StatusRepost" Source="/Resources/Images/Status_Repost.png" Margin="0,0,0,-2" Width="30"/>
                        <TextBlock x:Name="RepostCount"
    						Text="{Binding reposts_count}" 
    						d:LayoutOverrides="Width" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom" 
    						FontSize="18.667" Foreground="{StaticResource GreyBrush}"/>
                    </StackPanel>
                </Grid>

                <Path x:Name="Separater" Data="M0,80 L448,80" Height="1" Margin="0" Grid.Row="2" Grid.ColumnSpan="2" Stretch="Fill" UseLayoutRounding="False" VerticalAlignment="Top" HorizontalAlignment="Center">
                    <Path.Stroke>
                        <SolidColorBrush Color="White"/>
                    </Path.Stroke>
                </Path>
            </Grid>
        </DataTemplate>
        <Style x:Key="CustomScrollViewerStyle" TargetType="ScrollViewer">
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
            <Setter Property="VerticalScrollBarVisibility" Value="Visible"/>
            <Setter Property="Padding" Value="4"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9" Offset="0"/>
                        <GradientStop Color="#FF8399A9" Offset="0.375"/>
                        <GradientStop Color="#FF718597" Offset="0.375"/>
                        <GradientStop Color="#FF617584" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ScrollViewer">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                            <Grid Background="{TemplateBinding Background}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <ScrollContentPresenter x:Name="ScrollContentPresenter" Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"/>
                                <Rectangle Grid.Column="1" Fill="#FFE9EEF4" Grid.Row="1"/>
                                <ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Margin="0,-1,-1,-1" Minimum="0" Orientation="Vertical" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Width="5" Background="{StaticResource GreyBrush}" Opacity="0.3"/>
                                <ScrollBar x:Name="HorizontalScrollBar" Grid.Column="0" Height="18" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Margin="-1,0,-1,-1" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}"/>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="ListBoxControlTemplate" TargetType="ListBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" 
                          BorderThickness="{TemplateBinding BorderThickness}" 
                          Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}" 
                          Style="{StaticResource CustomScrollViewerStyle}" 
                          ManipulationCompleted="ListBox_ManipulationCompleted">
                <ItemsPresenter/>
            </ScrollViewer>
        </ControlTemplate>
    </phone:PhoneApplicationPage.Resources>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True">
            <shell:ApplicationBarIconButton x:Name="refreshIconButton" IconUri="/Resources/Icons/appbar_refresh.png" Text="刷新" Click="refreshIconButton_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Style="{StaticResource BackgroundStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="{StaticResource AppName}"  
                       Style="{StaticResource PhoneTextNormalStyle}" 
                       Foreground="{Binding Source={StaticResource AppSettings}, Path=colorSaved}"/>
            <TextBlock x:Name="PageTitle" Text="悄悄关注" Margin="9,-7,0,0" 
                       Style="{StaticResource PhoneTextTitle1Style}" 
                       Foreground="{Binding Source={StaticResource AppSettings}, Path=colorSaved}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,10" >
            <ListBox x:Name="secretTimeline"
                		ItemsSource="{Binding SecretTimelineList}"
                		ItemTemplate="{StaticResource StatusTemplateComplex}" Foreground="Black" Margin="0,1,0,0" HorizontalAlignment="Right"
                		SelectionChanged="secretTimeline_SelectionChanged" Template="{StaticResource ListBoxControlTemplate}" />
            <Button x:Name="toTopButton" HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                            Foreground="{StaticResource TransparentBrush}" 
                            BorderBrush="{StaticResource TransparentBrush}" 
                            Width="80" Height="80" Margin="-25,0,0,-20" Click="toTopButton_Click"
                            Visibility="Collapsed">
                <Button.Background>
                    <ImageBrush ImageSource="/MyDeeWeibo;component/Resources/Images/toTop.png" Opacity="0.4"/>
                </Button.Background>
            </Button>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
